using UnityEngine;
using System.Collections.Generic;
using UnityEngine.UI;

namespace Manaddiction
{
    public enum CardType
    {
        None = 0,
        Creature = 10,
        Spell = 20
    }

    [CreateAssetMenu(fileName = "card", menuName = "Manaddction/CardData", order = 1)]
    public class CardData : ScriptableObject
    {
        [Header("Display")]
        public string id;//卡的唯一id
        public string card_name;//卡名
        public Sprite card_image;//卡图

        public Sprite card_frame;//卡框
        public Sprite mana_bg;//法力值背景图
        public Sprite TnN_bg;//卡类别和名字背景图
        //public Sprite card_entity;//卡牌拿在手中时的显示（如召唤物的实体和咒语的特效）

        [Header("Stats")]
        public CardType type;
        public int mana;
        
        [Header("IfCreature")]
        public int attack;
        public int hp;
        public int execution;//行动力
        public int atk_distance;//攻击距离

        //[Header("Abilities")]
        //public AbilityData[] abilities;//异能（暂不启用）

        [Header("Card Effect")]
        [TextArea(3, 5)]
        public string effect_text;//异能描述

        //[Header("Description")]//卡牌描述
        //[TextArea(5, 10)]
        //public string desc;

        //[Header("FX")]//特效与声效
        //public GameObject spawn_fx;
        //public GameObject death_fx;
        //public GameObject attack_fx;
        //public GameObject damage_fx;
        //public GameObject idle_fx;
        //public AudioClip spawn_audio;
        //public AudioClip death_audio;
        //public AudioClip attack_audio;
        //public AudioClip damage_audio;

        //[Header("Availability")]
        //public bool deckbuilding = false;
        //public int cost = 100;
        //public PackData[] packs;
        
        public static List<CardData> card_list = new List<CardData>();

        //从Resources文件夹中加载所有卡牌数据 
        public static void Load(string folder = "")
        {
            if (card_list.Count == 0)
                card_list.AddRange(Resources.LoadAll<CardData>(folder));
        }
        
        //根据卡牌id获取CardData
        public static CardData Get(string id)
        {
            foreach (CardData card in GetAll())
            {
                if (card.id == id)
                    return card;
            }
            return null;
        }
        
        public static List<CardData> GetAll()
        {
            return card_list;
        }
    }
}
